import json
def generate_data(num):
   data_list = []
   for i in range(1, num + 1):
       data_dict = {
           "instruction": f"{i}" * 3,
           "input": f"{i}" * 3,
           "output": f"{i}" * 3
       }
       data_list.append(data_dict)
   return data_list



def read_and_output_file(file_path):
    
  try:
      data_list = [] 
      with open(file_path, 'r', encoding='utf-8') as file:
          for line_number, line in enumerate(file, start=1):
              line = line.strip()  # 去除行尾的换行符和空格
              if "发送数据给NCC" in line:
                  data_dict = {
                     "instruction": "查询integrati关键字",
                      "input": line,
                      "output": line
                  }
                  data_list.append(data_dict)

              else:
          #        print(line)
                  data_dict = {
                     "instruction": "查询integrati关键字",
                      "input": line,
                      "output": "NO"
                  }
                  data_list.append(data_dict)

  except FileNotFoundError:
      print(f"Error: The file '{file_path}' does not exist.")
  except Exception as e:
      print(f"An error occurred: {e}")
  json_string = json.dumps(data_list, indent=4,ensure_ascii=False)
  print(json_string)
 
def main():
  read_and_output_file('data')
 
if __name__ == "__main__":
  main()
